#include <chrono>
#include <functional>
#include <memory>
#include <string>
#include <sstream>
 
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/string.hpp"
 
using namespace std;
using namespace rclcpp;
uint32_t count1=0;

int main(int argc,char ** argv)
{
    rclcpp::init(argc,argv);
    //define a node
    Node node1("node1");
    Rate rate(1);
    std_msgs::msg::String message;
    //define a publisher
//    Publisher<std_msgs::msg::String>(&node1,"topicName"  , 10 );
    auto Publisher2 =node1.create_publisher<std_msgs::msg::String>("topicName",10 );//return value is a pointer
    while(ok())
    {
    stringstream ss;
        ss<<"hi im glad to see you"<<count1++<<endl;
        message.data=ss.str();
        cout<<message.data;
        Publisher2->publish(message);
        rate.sleep();//=sleep(10)
    }
 
    rclcpp::shutdown();
    return 0;
 
}
